<script type="text/javascript"> 
 
    $(document).ready(function(){ 
		// initialise Superfish 
        $("ul.sf-menu").superfish({ 
            pathClass:  'Photos' 
        }); 
        


        var file = 2;
		$("#attach_another").bind('click', function(){
			$("#photo").append('<div><input type="file" name="data[Photo][file'+file+']" value="" id="PhotoFile'+file+'" /></div>');
			file++;
		});

    }); 

	function del(id){
		if (confirm("Are you sure?")) {
	    	window.location.href = "<?=APP_ROOT;?>/apartments/deletePhoto/"+id;
		}
	}
</script>
<h2><?php echo $pageTitle; ?></h2>
<?php echo $form->create('Photo', array('type' => 'file',));?>

	
	<div id="tabs-3">
		<br />
		<div id="photo">
			<div id="attach_another" href="#" >
				<img src="<?=APP_ROOT?>/img/icons/Colored/GIF/action_add.gif">
			</div>
			<div><?php echo $form->file('Photo.file1');?></div>
		</div>
		<?php if(!empty($this->data)):?>
		<hr>List photos</hr>
		<div id="photo_list">
			<?php 
				foreach($photo as $current){
					
					echo $html->link(
										$html->image('Photos/small/'.$current['filename'], array('alt'=>SITE_NAME, 'style'=>'padding: 10px;')),
										'/img/Photos/big/'.$current['filename'],
										array('rel'=>'asdfasdf', 'escape'=>false, 'class'=>'thickbox', 'title'=>'add a caption to title attribute / or leave blank' )
									);
					?>
					<a title="delete" onclick="javascript:del(<? echo $current['id']; ?>)" href="#" style="position: relative; left: -19px;" ><img src="<?=APP_ROOT;?>/img/icons/Colored/GIF/action_delete.gif" /></a>
					<?php 
				}
				
				?>
		</div>
		<?php endif;?>
  	</div>
 
  	
	<input type="submit" name="Save" value="Save" />	
<?php echo $form->end();?>